<%@page contentType="text/html;charset=utf-8"%>
<!DOCTYPE html >
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>生成订单 - 当当网</title>
<link href="${pageContext.request.contextPath}/css/login.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath}/css/page_bottom.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.7.2.min.js"></script>

</head>
<body>
	<%@include file="../common/head1.jsp"%>
	<div class="login_step">
		添加收货地址：
	</div>
	<div class="fill_message">
	
		<form name="ctl00" action="${pageContext.request.contextPath}/address/addAddress.do"
			method="post" id="f" onsubmit="return checkForm()">
			<input type="hidden" name="id" id="addressId" />
			<table class="tab_login">
				<tr>
					<td valign="top" class="w1">收件人姓名：</td>
					<td><input onblur="checkname()" type="text" class="text_input"
						name="receive_name" id="receiveName" />
						<div class="text_left" id="nameValidMsg">
							<p>请填写有效的收件人姓名</p>
							<span id="nameinfo" style="color:red"></span>
						</div></td>
				</tr>
				<tr>
					<td valign="top" class="w1">收件人详细地址：</td>
					<td><input onblur="checkaddress()" type="text"
						name="address" class="text_input" id="fullAddress" />
						<div class="text_left" id="addressValidMsg">
							<p>请填写有效的收件人的详细地址</p>
							<span id="addressinfo" style="color:red"></span>
						</div></td>
				</tr>
				<tr>
					<td valign="top" class="w1">手机</td>
					<td><input onblur="checkmobile()" type="text"
						class="text_input" name="mobile" id="phone" />
						<div class="text_left" id="phoneValidMsg">
							<p>请填写有效的收件人的手机</p>
							<span id="mobileinfo" style="color:red"></span>
						</div></td>
				</tr>
			</table>

			<div class="login_in">
				<a href="javascript:history.go(-1);"><input id="btnClientRegister"
					class="button_1"  type="button" value="取消" /></a> <input
					id="btnClientRegister" class="button_1" name="submit" type="submit"
					value="添加" />
			</div>
			<input type="hidden" name="u_id" value="${sessionScope.user.id}"/>
			<input type="hidden" name="delete_status" value="0"/>
			<input type="hidden" name="selected_status" value="0"/>
		</form>
	</div>
	<%@include file="../common/foot1.jsp"%>
	<script type="text/javascript">
		function checkname() {
			let name = document.querySelector("#receiveName");
			let s = document.querySelector("#nameinfo");
			if(name.value != null && name.value.trim()!=""){
				s.innerHTML = "";
				return true;
			}else{
				s.innerHTML = "用户名不能为空";
				return false;
			}
		}
		function checkaddress() {
			let address = document.querySelector("#fullAddress");
			let s = document.querySelector("#addressinfo");
			if(address.value != null && address.value.trim()!=""){
				s.innerHTML = "";
				return true;
			}else{
				s.innerHTML = "地址不能为空";
				return false;
			}
		}
		function checkmobile() {
			let mobile = document.querySelector("#phone");
			let s = document.querySelector("#mobileinfo");
			let reg = /((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)/;
			if(reg.test(mobile.value)){
				s.innerHTML = "";
				return true;
			}else{
				s.innerHTML = "请输入正确的电话号码";
				return false;
			}
		}
		function checkForm() {
			if(checkname() && checkaddress() && checkmobile()){
				return true;
			}
			return false;
		}
	</script>
</body>
</html>

